<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">问卷列表</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <form class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
                            <div class="am-u-sm-12 am-u-md-3">
                                <div class="am-form-group">
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <?php if (checkPrivilege('content.survey/daochu')): ?>
                                                <a class="j-export am-btn am-btn-success am-radius"
                                                   href="javascript:void(0);">
                                                    <i class="iconfont icon-daochu am-margin-right-xs"></i>导出
                                                </a>
                                            <?php endif; ?>
                            
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="am-u-sm-12 am-u-md-9">
                                <div class="am fr">
                                    <div class="am-form-group am-fl">
                                        <?php $category_id = $request->get('survey_id') ?: null; ?>
                                        <select name="survey_id"
                                                data-am-selected="{searchBox: 1, btnSize: 'sm',  placeholder: '问卷类型', maxHeight: 400}">
                                            <option value=""></option>
                                            <?php if (isset($catgory)): foreach ($catgory as $first): ?>
                                                <option value="<?= $first['id'] ?>"
                                                    <?= $category_id == $first['id'] ? 'selected' : '' ?>>
                                                    <?= $first['title'] ?></option>
                                                
                                            <?php endforeach; endif; ?>
                                        </select>
                                    </div>
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form"> 
                                            <div class="am-form-group tpl-form-border-form am-fl">
                                                
                                                <input type="text" name="start_time"
                                                    class="am-form-field"
                                                    value="<?= $request->get('start_time') ?>" placeholder="请选择起始日期"
                                                    data-am-datepicker>
                                            </div> 
                                        </div> 
                                    </div> 
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form"> 
                                            <div class="am-form-group tpl-form-border-form am-fl">
                                                <input type="text" name="end_time"
                                                    class="am-form-field"
                                                    value="<?= $request->get('end_time') ?>" placeholder="请选择截止日期"
                                                data-am-datepicker>
                                                <div class="am-input-group-btn">
                                                    <button class="am-btn am-btn-default am-icon-search"
                                                        type="submit"></button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>问卷标题</th>
                                <th>用户</th>
                                <th>手机号</th>
                                <th>调研结果</th>
                                <th>时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr>
                                    <td class="am-text-middle"><?= $item['id'] ?></td>
                                    <td class="am-text-middle"><?= $item['title'] ?></td>
                                    <td class="am-text-middle">
                                        <p class="item-title"
                                           style="max-width: 400px;"><?= $item['jiuzhen_name'] ?></p>
                                    </td>
                                    <td class="am-text-middle">
                                        <p class="item-title"
                                           style="max-width: 400px;"><?= $item['jiuzhen_phone'] ?></p>
                                    </td>
                                    <td class="am-text-middle"><?= $item['answer_text'] ?></td>
                                    <td class="am-text-middle"><?= date("Y-m-d",$item['create_time']) ?></td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <?php if (checkPrivilege('content.survey/edit')): ?>
                                                <a href="<?= url('content.survey/info',
                                                    ['id' => $item['id']]) ?>">
                                                    <i class="am-icon-pencil"></i> 查看详情
                                                </a>
                                            <?php endif; ?>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="10" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?> </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total() ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        // alert(1);
        // 删除元素
        var url = "<?= url('content.survey/delete') ?>";
        $('.item-delete').delete('id', url);
        /**
         * 导出
         */
        $('.j-export').click(function () {
            // 获取筛选表单中的所有参数
            var formData = $('form.toolbar-form').serialize(); 
            // 拼接到导出 URL
            window.location = "<?= url('content.survey/daochu') ?>" + '?' + formData;
        });
    });
</script>

